<template>
  <div class="bottom">
    <div class="right">
      <div class="right-top">
        <h1>我的订单
          <small>
            请谨防钓鱼链接或诈骗电话，了解更多>
          </small>
        </h1>
      </div>
      <div class="right-end" v-if="token !== ''">
        <div class="">
          <div class=" main-box">
            <div class="box-hd">
              <div class="clearfix">
                <ul class="filter-list">
                  <a href="" style="color: #000;">
                    <li class="first-active1">全部有效订单</li>
                  </a>
                  <a href="" style="color: #000;">
                    <li class="first-active">待支付</li>
                  </a>
                  <a href="" style="color: #000;">
                    <li class="first-active">待收货</li>
                  </a>
                  <a href="" style="color: #000;">
                    <li class="first-active">订单回收站</li>
                  </a>
                </ul>
              </div>
            </div>
            <div class="box-bd" v-if="data.length <= 0">
              <div class="dingdandh">
                <ul class="order-list">
                  <p class="empty">当前没有任何交易订单。</p>
                </ul>
              </div>
            </div>
            <div class="tps">
              <div class="tp" v-for="item in data" :key="item.id">
                <div class="tupian">
                  <img :src="item.src" alt="">
                </div>
                <ul>
                  <h2>{{ item.Chinesename }}</h2>
                  <h2 style="color: #ff6700;">{{ item.price * item.num }}</h2>
                  <h3>{{ item.version1 }}</h3>
                  <span>数量：{{ item.num }}</span>
                  <div class="tk">
                    <div>
                      支持7天无理由退款-放心购
                      <span style="margin-left: 50px;">
                      </span>
                    </div>
                  </div>
                </ul>
                <div class="del" @click="delOrder(item.id)">删除订单</div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="right-end" v-if="token === ''">
        <div class="IsLogin">请先登录</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  created() {
    const savedToken = localStorage.getItem('token');
    if (savedToken) {
      this.token = savedToken;
    } else {
      this.token = '';
    }
  },
  data: {
    return() {
      return {
        token: '',
      }
    },
  },
  props: {
    data: {
      type: Array
    }
  },
  methods: {
    delOrder(id) {
      this.$emit('delOrder', id)
    }
  }
}
</script>

<style scoped>
.IsLogin {
  width: 120px;
  color: #666;
  margin: 0 auto;
  font-size: 25px;
}

/* 优化后的CSS */
.bottom {
  cursor: pointer;
  margin: 0 auto;
  background: #f5f5f5;
  width: 1240px;
  display: flex;
  justify-content: space-around;
}

.left {
  margin: 0 auto;
  background: #fff;
  width: 234px;
  height: 600px;
}

.leftbox {
  margin: 0 48px 12px;
  padding: 16px 0;
}

.leftbox h3 {
  font-size: 16px;
  font-weight: 400;
  line-height: 52px;
  color: #333;
  margin: 0;
}

.list {
  list-style: none;
}

.list li {
  padding: 3px 0;
  cursor: pointer;
  color: #666;
}

.list li:hover {
  color: #ff6700;
}

.right {
  margin: 0 auto;
  background: #fff;
  width: 978px;
}

.right-top {
  padding: 36px 48px;
}

.right-top h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
  line-height: 68px;
  color: #757575;
}

.tp {
  width: 800px;
  height: 200px;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  /* background-color: #e0e0e0; */
}

.tps {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.tupian {
  width: 200px;
  height: 200px;
}

.tupian img {
  width: 100%;
  max-width: 100%;
  height: auto;
}

.dingdandh,
.dingdan-list,
.box-bd {
  width: 882px;
}

.first-active2 {
  margin-left: 700px;
}

.empty {
  margin: 40px 0;
  font-size: 18px;
  text-align: center;
  color: #b0b0b0;
}

.search-from {
  /* float: right; */
  /* position: relative; */
  width: 262px;
  height: 40px;
  margin-top: 8px;
}

.search-text {
  position: absolute;
  top: 0;
  border: 1px solid #e0e0e0;
  outline: 0;
  transition: all .2s;
  width: 221px;
  height: 42px;
}

.filter-list {
  margin: 0;
  padding: 18px 0;
  list-style-type: none;
  font-size: 16px;
  line-height: 1.25;
  display: flex;
  justify-content: space-around;
}

.clearfix {
  width: 882px;
  height: 56px;
}

.h1title {
  margin: 0;
  font-size: 30px;
  font-weight: 400;
  line-height: 68px;
  color: #757575;
}

.del {
  width: 100px;
  height: 40px;
  text-align: center;
  line-height: 40px;
  background: #f24501;
  border-radius: 20%;
}
</style>